package zemberek3.lexicon;

import com.google.common.collect.Sets;
import zemberek3.structure.IdItem;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * A convenience class for grouping Id Items.
 */
public class IdItemGroup<T extends IdItem> extends IdItem implements Iterable<T> {
    Set<T> lexicalForms = new HashSet<T>();

    public IdItemGroup(String id, T... suffixes) {
        this.id = id;
        this.lexicalForms = Sets.newHashSet(suffixes);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        IdItemGroup that = (IdItemGroup) o;

        return id.equals(that.id);

    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }

    @Override
    public Iterator<T> iterator() {
        return lexicalForms.iterator();
    }
}
